package com.lwy.unos.stuinfo.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.lwy.unos.stuinfo.entity.GradeInfoEntity;
import com.lwy.unos.stuinfo.service.GradeInfoService;
import com.lwy.common.utils.PageUtils;
import com.lwy.common.utils.R;



/**
 * 
 *
 * @author weizhennan
 * @email weizhennan@gmail.com
 * @date 2020-11-05 19:54:44
 */
@RestController
@RequestMapping("stuinfo/gradeinfo")
public class GradeInfoController {
    @Autowired
    private GradeInfoService gradeInfoService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public List<GradeInfoEntity> list(){
        List<GradeInfoEntity> list = gradeInfoService.list();
        return list;
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{gradeId}")
    public R info(@PathVariable("gradeId") Integer gradeId){
		GradeInfoEntity gradeInfo = gradeInfoService.getById(gradeId);

        return R.ok().put("gradeInfo", gradeInfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody GradeInfoEntity gradeInfo){
		gradeInfoService.save(gradeInfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody GradeInfoEntity gradeInfo){
		gradeInfoService.updateById(gradeInfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] gradeIds){
		gradeInfoService.removeByIds(Arrays.asList(gradeIds));

        return R.ok();
    }

}
